//默认material库
import 'package:flutter/material.dart';
/*
使用ios的页面切换风格
1、注释import 'package:flutter/material.dart';
2、把下方的MaterialPageRoute替换成CupertinoPageRoute
 */
// import 'package:flutter/cupertino.dart';

//引入底部导航栏
import '../pages/add/add.dart';
import '../pages/device/ScanPage.dart';
import '../pages/home_page.dart';
import '../pages/login/page/login_page.dart';
import '../pages/my/setting_page.dart';
import '../pages/my/theme_page.dart';
import '../pages/tabs.dart';
//引入跳转页面
import '../pages/form.dart';
import '../pages/search.dart';
import '../pages/login.dart';
import '../pages/shop.dart';
//用户页面
// import '../user/login.dart';
import '../pages/tabs/home3.dart';
import '../user/registerFirst.dart';
import '../user/registerSecond.dart';
import '../user/registerThird.dart';


//其他页面
import '../pages/tabs/hero.dart';
import '../pages/my/trends.dart';
import '../pages/my/orders.dart';
import '../pages/my/userEdit.dart';
import '../pages/tabs/heroTo.dart';

import '../pages/device/device.dart';
import '../pages/device/qrcode.dart' hide ScanPage;
import '../pages/device/qr_code_scanner_page.dart';

//1、配置路由
final Map routes = {
  //全局路由
  // "/": (context) => const Tabs(),
  // "/": (context) => const Home(),
  "/": (context) => const LoginPage(),
  "/home": (context) => const Home(),

  //跳转路由
  "/search": (context) => const SearchPage(),
  "/LoginX": (context) =>  Login(),
  // "form": (context, {aid}){
  //   //传值
  //   return FormPage(aid: aid);
  // }
  "/form": (context, {arguments}) => FormPage(aid: arguments),
  //命名路由，传值
  "/shop": (context, {arguments}) => ShopPage(arguments: arguments),
  // "/login": (contxt) => const LoginPage(),
  "/registerFirst": (contxt) => const RegisterFirstPage(),
  "/registerSecond": (contxt) => const RegisterSecondPage(),
  "/registerThird": (contxt) => const RegisterThirdPage(),



  "/trends": (contxt) => const TrendsPage(),
  "/orders": (contxt) => const OrdersPage(),
  "/userEdit": (contxt) => const UserEditPage(),


  "/device": (contxt) =>  DevicePage(),
  // "/qrcode": (contxt) =>  QrCodePage(),
  // "/qrcodeScanner": (contxt) =>  QrCodeScannerPage(),
  "/qrcodeScanner": (contxt) =>  ScanPage(),

  "/hero": (contxt) => const HeroData(),
  "/heroTo": (contxt, {arguments}) => HeroTo(arguments:arguments),


  "/addDevice": (contxt) => const AddPage(),
  "/settingPage": (contxt) => const SettingPage(),
  "/themePage": (contxt) => const ThemePage(),
  // "/loginNew": (contxt) => const LoginPage(),


};


//2、配置onGenerateRoute 以下固定写法
//这个方法也相当于中间件，可以做权限
var onGenerateRoute = (RouteSettings settings) {
  // 统一处理
  final String? name = settings.name;
  final Function? pageContentBuilder = routes[name];
  if (pageContentBuilder != null) {
    if (settings.arguments != null) {
      final Route route = MaterialPageRoute(
      // final Route route = CupertinoPageRoute(
          builder: (context) =>
              pageContentBuilder(context, arguments: settings.arguments));
      return route;
    } else {
      final Route route = MaterialPageRoute(
      // final Route route = CupertinoPageRoute(
          builder: (context) => pageContentBuilder(context));
      return route;
    }
  }
  return null;
};


